package com.job.handler;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * 开发公司：联信
 * 版权：联信
 * <p>
 * Annotation
 *
 * @author 刘志强
 * @created Create Time: 2021/3/2
 */
@Component
public class TestJobHandler {
    private Logger logger= LoggerFactory.getLogger(TestJobHandler.class);
    @Resource
    private RestTemplate restTemplate;

    /**
     * 访问一个地址
     * @param param
     * @return
     * @throws Exception
     */
    @XxlJob("test")
    public ReturnT<String> demoJobHandler(String param) throws Exception {
        logger.info("XXL-JOB, Hello World.");
        ResponseEntity<String> responseEntity = restTemplate.getForEntity("http://www.baidu.com", String.class);
        logger.info(responseEntity.getBody());
        return ReturnT.SUCCESS;
    }

}
